﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Windows;
using Microsoft.Phone.Controls;
using WSClient.DictionaryService;
using WSClient.BookStoreHQ;
using System.IO.IsolatedStorage;

namespace WSClient
{
    public partial class MainPage : PhoneApplicationPage
    {
        private MobileClientWSClient _mobileWsClient;


        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void LoginButtonClicked(object sender, RoutedEventArgs e)
        {
            var client = GetMobileWsClient();
            client.loginCompleted += LoginCompleted;
            client.loginAsync("kundzia","1234");
        }

        private void LoginCompleted(object sender, loginCompletedEventArgs e)
        {
            var a= e.Error.GetType();
            var b = e.Error.GetBaseException();
            var c = (FaultException<kupencja>)e.Error;
            
           // kupencja b = (kupencja) a.Reason;
            MessageBox.Show(e.Result);
        }


        public MobileClientWSClient GetMobileWsClient()
        {
            //singleton
            return _mobileWsClient ?? (_mobileWsClient = new MobileClientWSClient());
        }

        private void PhoneApplicationPageLoaded(object sender, RoutedEventArgs e)
        {

        }

   

       
    }
}